<?php

namespace app\admin\model\todo;

use think\Model;


class Withdrawal extends Model
{

    

    

    // 表名
    protected $name = 'xiservice_user';
    
    // 自动写入时间戳字段
    protected $autoWriteTimestamp = 'integer';

    // 定义时间戳字段名
    protected $createTime = 'createtime';
    protected $updateTime = 'updatetime';
    protected $deleteTime = false;

    // 追加属性
    protected $append = [
        'work_status_text',
        'checkinfo_text',
        'status_text',
        'vip_type_text',
        'vip_end_time_text',
        'bond_status_text',
        'is_block_text'
    ];
    

    
    public function getWorkStatusList()
    {
        return ['0' => __('Work_status 0'), '1' => __('Work_status 1')];
    }

    public function getCheckinfoList()
    {
        return ['0' => __('Checkinfo 0'), '1' => __('Checkinfo 1'), '2' => __('Checkinfo 2')];
    }

    public function getStatusList()
    {
        return ['1' => __('Status 1'), '0' => __('Status 0')];
    }

    public function getVipTypeList()
    {
        return ['0' => __('Vip_type 0'), '1' => __('Vip_type 1'), '2' => __('Vip_type 2')];
    }

    public function getBondStatusList()
    {
        return ['1' => __('Bond_status 1'), '2' => __('Bond_status 2')];
    }

    public function getIsBlockList()
    {
        return ['1' => __('Is_block 1'), '2' => __('Is_block 2')];
    }


    public function getWorkStatusTextAttr($value, $data)
    {
        $value = $value ? $value : (isset($data['work_status']) ? $data['work_status'] : '');
        $list = $this->getWorkStatusList();
        return isset($list[$value]) ? $list[$value] : '';
    }


    public function getCheckinfoTextAttr($value, $data)
    {
        $value = $value ? $value : (isset($data['checkinfo']) ? $data['checkinfo'] : '');
        $list = $this->getCheckinfoList();
        return isset($list[$value]) ? $list[$value] : '';
    }


    public function getStatusTextAttr($value, $data)
    {
        $value = $value ? $value : (isset($data['status']) ? $data['status'] : '');
        $list = $this->getStatusList();
        return isset($list[$value]) ? $list[$value] : '';
    }


    public function getVipTypeTextAttr($value, $data)
    {
        $value = $value ? $value : (isset($data['vip_type']) ? $data['vip_type'] : '');
        $list = $this->getVipTypeList();
        return isset($list[$value]) ? $list[$value] : '';
    }


    public function getVipEndTimeTextAttr($value, $data)
    {
        $value = $value ? $value : (isset($data['vip_end_time']) ? $data['vip_end_time'] : '');
        return is_numeric($value) ? date("Y-m-d H:i:s", $value) : $value;
    }


    public function getBondStatusTextAttr($value, $data)
    {
        $value = $value ? $value : (isset($data['bond_status']) ? $data['bond_status'] : '');
        $list = $this->getBondStatusList();
        return isset($list[$value]) ? $list[$value] : '';
    }


    public function getIsBlockTextAttr($value, $data)
    {
        $value = $value ? $value : (isset($data['is_block']) ? $data['is_block'] : '');
        $list = $this->getIsBlockList();
        return isset($list[$value]) ? $list[$value] : '';
    }

    protected function setVipEndTimeAttr($value)
    {
        return $value === '' ? null : ($value && !is_numeric($value) ? strtotime($value) : $value);
    }


}
